<report title="QIDSS Search for Missing Prevention's in Patient Chart" description="Patient that has never had a specified prevention type and searched by YOB that is greater than or equal to the YOB specified. " active="1">

<query>

select

demographic_no As Demo,
d.sex as Gender,
concat(d.last_name, ", ", d.first_name) as Name ,
YEAR(CURDATE()) - YEAR(concat(year_of_birth,month_of_birth,date_of_birth)) as 'Age',
concat(year_of_birth,'-', month_of_birth,'-',date_of_birth) as DOB,
roster_status,
patient_status,
concat(p.first_name, ",", p.last_name) as MRP

from demographic d
LEFT JOIN provider p on p.provider_no= d.provider_no

where
year_of_birth <='{year_of_birth}'
and
demographic_no NOT IN ( select demographic_no from preventions where prevention_type = '{prevention_type}')
and d.patient_status ='{patient_status}'
and d.roster_status = '{roster_status}'
and d.sex in ('{sex}')

order by DOB desc ;

</query>
<param id="prevention_type" type="textlist" description="Prevention Type">
</param>
<param id="year_of_birth" type="textlist" description="Year of Birth >=">
</param>
<param id="patient_status" type="textlist" description="Patient Status">
</param>
<param id="roster_status" type="textlist" description="Roster Status">
</param>
<param id="sex" type="textlist" description="sex">
</param>

</report>